package com.henu.acmrating.controller;

import com.henu.acmrating.common.Result;
import com.henu.acmrating.pojo.WeekStar;
import com.henu.acmrating.service.WeekStarService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/api")
public class WeekStarController {

    @Resource
    WeekStarService weekStarService;

    /**
     * 从数据库拿到 每周之星
     */
    @RequestMapping(value = "/weekStar", method = RequestMethod.GET)
    public Result weekStar() {
        List<WeekStar> weekStars = weekStarService.selectAll();
        if(weekStars.size() == 0) {
            return Result.success("每周之星周一更新");
        }
        return Result.success(weekStars.get(0).getUserName());
    }
}
